import { lazy } from 'react';

// 懒加载组件
const Login = lazy(() => import('../pages/Login.jsx'));
const Layout = lazy(() => import('../layouts/Layout.jsx'));
const Dashboard = lazy(() => import('../pages/Dashboard.jsx'));
const CouponManagement = lazy(() => import('../pages/CouponManagement.jsx'));
const DiscountCardManagement = lazy(() => import('../pages/DiscountCardManagement.jsx'));
const ThresholdPromotionManagement = lazy(() => import('../pages/ThresholdPromotionManagement.jsx'));
const CountCardManagement = lazy(() => import('../pages/CountCardManagement.jsx'));
const MChooseNCardManagement = lazy(() => import('../pages/MChooseNCardManagement.jsx'));
const PackageCardManagement = lazy(() => import('../pages/PackageCardManagement.jsx'));
const UserManagement = lazy(() => import('../pages/UserManagement.jsx'));
const ActivityAnalysis = lazy(() => import('../pages/ActivityAnalysis.jsx'));
const NotFound = lazy(() => import('../pages/NotFound.jsx'));

// 路由配置
const routes = [
  // 登录页不需要布局和权限
  {
    path: '/login',
    component: Login,
    exact: true,
    requiresAuth: false,
  },
  
  // 主布局下的路由，需要认证
  {
    path: '/',
    component: Layout,
    requiresAuth: true,
    routes: [
      // 仪表盘
      {
        path: '/',
        component: Dashboard,
        exact: true,
        name: '仪表盘',
        icon: 'dashboard',
        permissions: ['DASHBOARD_VIEW'],
      },
      
      // 优惠券管理
      {
        path: '/coupons',
        component: CouponManagement,
        name: '优惠券管理',
        icon: 'ticket',
        permissions: ['COUPON_MANAGE'],
      },
      
      // 折扣卡管理
      {
        path: '/discount-cards',
        component: DiscountCardManagement,
        name: '折扣卡管理',
        icon: 'discount',
        permissions: ['DISCOUNT_CARD_MANAGE'],
      },
      
      // 满减活动管理
      {
        path: '/threshold-promotions',
        component: ThresholdPromotionManagement,
        name: '满减活动管理',
        icon: 'gift',
        permissions: ['THRESHOLD_PROMOTION_MANAGE'],
      },
      
      // 次数权益卡管理
      {
        path: '/count-cards',
        component: CountCardManagement,
        name: '次数权益卡管理',
        icon: 'ordered-list',
        permissions: ['COUNT_CARD_MANAGE'],
      },
      
      // M选N权益卡管理
      {
        path: '/m-choose-n-cards',
        component: MChooseNCardManagement,
        name: 'M选N权益卡管理',
        icon: 'select',
        permissions: ['M_CHOOSE_N_CARD_MANAGE'],
      },
      
      // 套餐卡管理
      {
        path: '/package-cards',
        component: PackageCardManagement,
        name: '套餐卡管理',
        icon: 'box',
        permissions: ['PACKAGE_CARD_MANAGE'],
      },
      
      // 用户管理
      {
        path: '/users',
        component: UserManagement,
        name: '用户管理',
        icon: 'user',
        permissions: ['USER_MANAGE'],
      },
      
      // 活动数据分析
      {
        path: '/analysis',
        component: ActivityAnalysis,
        name: '活动数据分析',
        icon: 'bar-chart',
        permissions: ['ANALYSIS_VIEW'],
      },
    ],
  },
  
  // 404 页面
  {
    path: '*',
    component: NotFound,
    requiresAuth: false,
  },
];

export default routes;